<!DOCTYPE html>
<html>
<head>
	<title>侧边栏停靠</title>
	<meta charset="utf-8">
	<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
	<style type="text/css">
		.affixed-element-top.affix{
			top: 10px;
		}
		.affixed-element-top.affix-bottom{
			position: relative;
		}
		.affixed-element-bottom.affix{
			bottom: 10px;
		}
		.affixed-element-bottom.affix-bottom{
			position: relative;
		}
	</style>
</head>
<body>
	<div class="container">
		<div class="col-md-3">
			<ul class="list-group affixed-element-top js-affixed-element-top">
				<li class="list-group-item">Hello大家好！！！</li>
				<li class="list-group-item">Hello大家好！！！</li>
				<li class="list-group-item">Hello大家好！！！</li>
				<li class="list-group-item">Hello大家好！！！</li>
				<li class="list-group-item">Hello大家好！！！</li>
				<li class="list-group-item">Hello大家好！！！</li>
			</ul>
		</div>
		<div class="col-md-6 is-content">
			<p>Positioning via CSS
The affix plugin toggles between three classes, each representing a particular state: .affix, .affix-top, and .affix-bottom. You must provide the styles, with the exception of position: fixed; on .affix, for these classes yourself (independent of this plugin) to handle the actual positions.

Here's how the affix plugin works:</p>

<p>To start, the plugin adds .affix-top to indicate the element is in its top-most position. At this point no CSS positioning is required.
Scrolling past the element you want affixed should trigger the actual affixing. This is where .affix replaces .affix-top and sets position: fixed; (provided by Bootstrap's CSS).
If a bottom offset is defined, scrolling past it should replace .affix with .affix-bottom. Since offsets are optional, setting one requires you to set the appropriate CSS. In this case, add position: absolute; when necessary. The plugin uses the data attribute or JavaScript option to determine where to position the element from there.
Follow the above steps to set your CSS for either of the usage options below.</p>

<p>Via data attributes
To easily add affix behavior to any element, just add data-spy="affix" to the element you want to spy on. Use offsets to define when to toggle the pinning of an element.</p>
<p>Positioning via CSS
The affix plugin toggles between three classes, each representing a particular state: .affix, .affix-top, and .affix-bottom. You must provide the styles, with the exception of position: fixed; on .affix, for these classes yourself (independent of this plugin) to handle the actual positions.

Here's how the affix plugin works:</p>

<p>To start, the plugin adds .affix-top to indicate the element is in its top-most position. At this point no CSS positioning is required.
Scrolling past the element you want affixed should trigger the actual affixing. This is where .affix replaces .affix-top and sets position: fixed; (provided by Bootstrap's CSS).
If a bottom offset is defined, scrolling past it should replace .affix with .affix-bottom. Since offsets are optional, setting one requires you to set the appropriate CSS. In this case, add position: absolute; when necessary. The plugin uses the data attribute or JavaScript option to determine where to position the element from there.
Follow the above steps to set your CSS for either of the usage options below.

Via data attributes
To easily add affix behavior to any element, just add data-spy="affix" to the element you want to spy on. Use offsets to define when to toggle the pinning of an element.</p>
<p>Positioning via CSS
The affix plugin toggles between three classes, each representing a particular state: .affix, .affix-top, and .affix-bottom. You must provide the styles, with the exception of position: fixed; on .affix, for these classes yourself (independent of this plugin) to handle the actual positions.

Here's how the affix plugin works:</p>

<p>To start, the plugin adds .affix-top to indicate the element is in its top-most position. At this point no CSS positioning is required.
Scrolling past the element you want affixed should trigger the actual affixing. This is where .affix replaces .affix-top and sets position: fixed; (provided by Bootstrap's CSS).
If a bottom offset is defined, scrolling past it should replace .affix with .affix-bottom. Since offsets are optional, setting one requires you to set the appropriate CSS. In this case, add position: absolute; when necessary. The plugin uses the data attribute or JavaScript option to determine where to position the element from there.
Follow the above steps to set your CSS for either of the usage options below.</p>

<p>Via data attributes
To easily add affix behavior to any element, just add data-spy="affix" to the element you want to spy on. Use offsets to define when to toggle the pinning of an element.</p>
<p>Positioning via CSS
The affix plugin toggles between three classes, each representing a particular state: .affix, .affix-top, and .affix-bottom. You must provide the styles, with the exception of position: fixed; on .affix, for these classes yourself (independent of this plugin) to handle the actual positions.

Here's how the affix plugin works:</p>

<p>To start, the plugin adds .affix-top to indicate the element is in its top-most position. At this point no CSS positioning is required.
Scrolling past the element you want affixed should trigger the actual affixing. This is where .affix replaces .affix-top and sets position: fixed; (provided by Bootstrap's CSS).
If a bottom offset is defined, scrolling past it should replace .affix with .affix-bottom. Since offsets are optional, setting one requires you to set the appropriate CSS. In this case, add position: absolute; when necessary. The plugin uses the data attribute or JavaScript option to determine where to position the element from there.
Follow the above steps to set your CSS for either of the usage options below.

Via data attributes
To easily add affix behavior to any element, just add data-spy="affix" to the element you want to spy on. Use offsets to define when to toggle the pinning of an element.</p>
		</div>
		<div class="col-md-3">
			<ul class="list-group affixed-element-bottom js-affixed-element-bottom">
				<li class="list-group-item">Here's how the affix plugin works:</li>
				<li class="list-group-item">Here's how the affix plugin works:</li>
				<li class="list-group-item">Here's how the affix plugin works:</li>
				<li class="list-group-item">Here's how the affix plugin works:</li>
				<li class="list-group-item">Here's how the affix plugin works:</li>
				<li class="list-group-item">Here's how the affix plugin works:</li>
			</ul>
		</div>		
	</div>

<script type="text/javascript" src="js/jquery-3.0.0.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript">
	// 进行初始化
	$(function(){
		$('.js-affixed-element-top').affix({
			offset:{

			}
		})
		$('.js-affixed-element-bottom').affix({
			offset:{
				// 可以根据需要自己调整
				// bottom:200;
			}
		})
	})
</script>
</body>
</html>